package com.spbl;

import com.spbl.common.PasswordEncryptUtil;
import com.spbl.entity.SysUser;
import com.spbl.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.List;

/**
 * Description(这里用一句话描述这个方法的作用)
 * author: Gao xueyong
 * Create at: 2020/6/12 9:03 下午
 */
@Slf4j
@SpringBootTest
public class PasswordEncrypt {
    @Autowired
    SysUserService sysUserService;

    @Test
    public void updateUserPassword() {
        String enctyPassword;
        List<SysUser> sysUserList = sysUserService.getSysUserList(new HashMap<>());
        for(SysUser sysUser:sysUserList){
            if(sysUser.getLoginName().equals("admin")){
                enctyPassword = PasswordEncryptUtil.encryPassword("123", sysUser.getLoginName());
                log.info("{}={}",sysUser.getName(),enctyPassword);
                sysUser.setPassword(enctyPassword);
                sysUserService.updateSysUser(sysUser);
            }
        }

    }
}
